package net.hn.hnms.sys.file.config;

import org.springframework.boot.web.servlet.MultipartConfigFactory;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.util.unit.DataSize;

import javax.servlet.MultipartConfigElement;

import static org.springframework.util.unit.DataUnit.MEGABYTES;
@Configuration
public class MultipartConfig {

    @Bean
    public MultipartConfigElement multipartConfigElement() {
        long maxFileSize = 100l;
        long maxRequestSize = 200l;
        MultipartConfigFactory factory = new MultipartConfigFactory();
        factory.setMaxFileSize(DataSize.of(maxFileSize ,MEGABYTES));
        factory.setMaxRequestSize(DataSize.of(maxRequestSize ,MEGABYTES));
        return factory.createMultipartConfig();
    }

}
